package com.fxcalibre.onlineServices.imdb;

import java.util.HashMap;
import java.util.List;

import com.fxcalibre.onlineServices.beans.TitleResult;
import com.fxcalibre.onlineServices.imdb.parser.ImdbDetailParser;
import com.fxcalibre.onlineServices.imdb.parser.ImdbTitleSearchParser;
import com.fxcalibre.utils.HTTPUtils;
import com.fxcalibre.utils.LookupVO;

public class ImdbTitleSearch
{

	public static HashMap<String, String> findById(String imdbId)
	{
		LookupVO lookupVO = new LookupVO();
		lookupVO.setUrl("http://www.imdb.com" + imdbId);
		lookupVO = HTTPUtils.sendRequest(lookupVO);
		System.out.println(lookupVO.getResult());
		return ImdbDetailParser.parse(lookupVO.getResult());
	}

	public static List<TitleResult> search(String title)
	{
		LookupVO lookupVO = new LookupVO();
		lookupVO.setUrl("http://www.imdb.com/search/title?title=" + title);
		lookupVO = HTTPUtils.sendRequest(lookupVO);

		return ImdbTitleSearchParser.parse(lookupVO.getResult());
	}

	public static void main(String[] args)
	{
		System.out.println(ImdbTitleSearch.findById("/title/tt0137523"));
	}
}
